<template>
  <div>
    <div class="header flex-between">
        <div class="menu">
          <div 
            class="tab"
            v-for="tabItem in tabMenuList"
            :key="tabItem.tabId"
            :class="{active: tabItem.tabPath == activePath}" 
            @click="checkMune(tabItem.tabPath)"
          >
            {{tabItem.tabName}}
          </div>
        </div>
        <div class="right-box">
          <div class="serch-box">
            <input type="search" name="menu-search" placeholder="菜单搜索">
          </div>
          <el-tooltip class="info-box" content="退出登录" placement="top">
            <img src="../assets/imgs/msg.png" alt="" srcset="" @click="logOut">
          </el-tooltip>
        </div>
    </div>
  </div>
</template>
<script>

export default{
    name: 'HeaderNav',
    props: {
      childMenuList: []
    },
    data() {
      return {
        tabMenuList: this.childMenuList,
        isActive: true,
        activePath: ''
      }
    },
    watch: {
      childMenuList(newVal) {
        this.tabMenuList = newVal
        this.activePath = this.$route.path
      },
    },
    created() {
      this.activePath = this.$route.path
    },
    methods: {
      checkMune(tabPath) {
        this.$emit('handleChange',tabPath,0)
        this.activePath = tabPath;
      },
      logOut() {
        this.$router.push('/login')
      }
    }
}
</script>

<style lang="less" scoped>
.header {
    padding: 0 43px;
    height: 80px;
    background-color: #fff;
    box-shadow: 1px;
}
.right-box {
  display: flex;
  align-items: center;
  height: 40px;
  .serch-box {
    margin-right: 38px;
    height: 100%;
    width: 284px;
    input {
      border: none;
      border-radius: 20px;
      width: 100%;
      height: 100%;
      padding: 0 20px;
      background-color: #F2F2F2;
      outline: none;
    }
  }
  .info-box {
    width: 24px;
    height: 24px;
    img {
        width: 100%;
    }
  }
  .info-box:hover {
    scale: 1.1;
    cursor: pointer;
  }
}
.menu {
  display: flex;
  justify-content: space-around;
  height: 48px;
  width: 344px;
  .tab {
    height: 100%;
    line-height: 48px;
  }
  .tab:hover {
    color: #00CCCC;
    cursor: pointer;
  }
}
.active {
  color: #00CCCC;
  border-bottom: solid 3px #00CCCC;
}
</style>
